



//
//  MyCollection.m
//  GoShops
//
//  Created by zcj on 15-11-23.
//  Copyright (c) 2015年 郑朝军. All rights reserved.
//

#import "MyCollection.h"
#import "Grouble.h"
#import "NSString+JFColorString.h"
#import "HomeServiceModel.h"

@interface MyCollection()
@property (nonatomic,weak)UIView * backView;

@end
@implementation MyCollection
+ (instancetype)MyCollection:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * ID = @"mycollection";
    MyCollection * cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
    return cell;
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIView * backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
        backView.backgroundColor = [UIColor blackColor];
        [self addSubview:backView];
        self.backView = backView;
        
        CGFloat hightImg =  self.frame.size.height * 0.8;
        CGFloat width = self.frame.size.width;
       
        CGRect imgRect = CGRectMake(0, 0, width, hightImg);
        
        UIImageView * topView = [[UIImageView alloc]initWithFrame:imgRect];
        [backView addSubview:topView];
        
        self.topView = topView;
        
        CGFloat bootemH = self.frame.size.height - hightImg;
        CGFloat bottemY = CGRectGetMaxY(imgRect)+5;
        
        UILabel * bootem = [[UILabel alloc]initWithFrame:CGRectMake(0, bottemY, width, bootemH)];
        bootem.font = [UIFont systemFontOfSize:12];
        bootem.textColor = [UIColor whiteColor];
        bootem.textAlignment = NSTextAlignmentCenter;
        [backView addSubview:bootem];
        self.bootem = bootem;
        // Initialization code
    }
    return self;
}
- (void)setHomeModel:(HomeServiceModel *)homeModel
{
    _homeModel = homeModel;
    self.backView.backgroundColor = [homeModel.background stringTOColor:homeModel.background];
    
    [self.topView setImageWithURL:[NSURL URLWithString:homeModel.cateImgUrl] placeholderImage:[UIImage imageNamed:@"faminary"]];
    ZCJLog(@"%@",homeModel.cateImgUrl);
    
    self.bootem.text = homeModel.cateName;

}

@end
